home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / ActiveX Controlls / CD Writer Pro ActiveX Control / CD Writer Pro ActiveX Control.exe / %MAINDIR% / VBSample1 / frmErase.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2003-04-16  |  6.6 KB  |  188 lines

  1. VERSION 5.00
  2. Begin VB.Form frmErase 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Erase Re-Writable CD"
  5.    ClientHeight    =   1875
  6.    ClientLeft      =   2760
  7.    ClientTop       =   3750
  8.    ClientWidth     =   5490
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   1875
  13.    ScaleWidth      =   5490
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.CommandButton cmdCancel 
  17.       Caption         =   "&Cancel"
  18.       Height          =   375
  19.       Left            =   4065
  20.       TabIndex        =   4
  21.       Top             =   525
  22.       Width           =   1215
  23.    End
  24.    Begin VB.CheckBox chkQuikErase 
  25.       Caption         =   "Perform Quick Erase"
  26.       Height          =   225
  27.       Left            =   300
  28.       TabIndex        =   1
  29.       Top             =   180
  30.       Value           =   1  'Checked
  31.       Width           =   2160
  32.    End
  33.    Begin VB.CommandButton cmdErase 
  34.       Caption         =   "&Erase"
  35.       Height          =   375
  36.       Left            =   4065
  37.       TabIndex        =   0
  38.       Top             =   90
  39.       Width           =   1215
  40.    End
  41.    Begin VB.Label lblStatus 
  42.       Alignment       =   2  'Center
  43.       BeginProperty Font 
  44.          Name            =   "MS Sans Serif"
  45.          Size            =   8.25
  46.          Charset         =   0
  47.          Weight          =   700
  48.          Underline       =   0   'False
  49.          Italic          =   0   'False
  50.          Strikethrough   =   0   'False
  51.       EndProperty
  52.       Height          =   240
  53.       Left            =   1140
  54.       TabIndex        =   3
  55.       Top             =   1560
  56.       Width           =   3210
  57.    End
  58.    Begin VB.Label lblEraseMsg 
  59.       Caption         =   $"frmErase.frx":0000
  60.       Height          =   960
  61.       Left            =   285
  62.       TabIndex        =   2
  63.       Top             =   495
  64.       Width           =   3525
  65.    End
  66. Attribute VB_Name = "frmErase"
  67. Attribute VB_GlobalNameSpace = False
  68. Attribute VB_Creatable = False
  69. Attribute VB_PredeclaredId = True
  70. Attribute VB_Exposed = False
  71. Option Explicit
  72. Private WithEvents mobjCDPro As CDWriterPro
  73. Attribute mobjCDPro.VB_VarHelpID = -1
  74. Private mblnErasing As Boolean
  75. '****************************************************************
  76. '****************************************************************
  77. 'COPYRIGHT 2003 NUMEDIA SOFT, INC.
  78. 'This is a sample of how you could use the DVDWriterPro control.
  79. 'There are improvements which could be made rather easily.
  80. 'Feel free to modify it as you see fit.
  81. '****************************************************************
  82. '****************************************************************
  83. Private Sub cmdCancel_Click()
  84.     'Unload
  85.     Unload Me
  86. End Sub
  87. Private Sub cmdErase_Click()
  88.     Dim MediaType As eMediaType
  89.     Dim bCanErase As Boolean
  90.     'Lets get the media type
  91.     MediaType = mobjCDPro.GetMediaType()
  92.     'Check for media
  93.     If MediaType = mtNotLoaded Then
  94.         MsgBox "No Media Loaded.", vbOKOnly + vbInformation, App.Title
  95.         Unload Me
  96.         Exit Sub
  97.     End If
  98.     'Is media rewritable type
  99.     If (MediaType <> mtCDRW) And (MediaType <> mtDVDMRW) And _
  100.         (MediaType <> mtDVDRam) And (MediaType <> mtDVDPRW) Then
  101.         'Msg to user
  102.         MsgBox "The current media is not Re-Writable.", vbOKOnly + vbInformation, App.Title
  103.         Unload Me
  104.         Exit Sub
  105.     End If
  106.     'Defualt Erase flag
  107.     bCanErase = False
  108.     'Check to see if drive is capable of erasing this type of media
  109.     If (mobjCDPro.GetDriveCapabilityFlag(WriteCDRW) = True) And (MediaType = mtCDRW) Then
  110.         bCanErase = True
  111.     ElseIf (mobjCDPro.GetDriveCapabilityFlag(WriteDVDRW) = True) And (MediaType = mtDVDMRW) Then
  112.         bCanErase = True
  113.     ElseIf (mobjCDPro.GetDriveCapabilityFlag(WriteDVDRam) = True) And (MediaType = mtDVDRam) Then
  114.         bCanErase = True
  115.     ElseIf (mobjCDPro.GetDriveCapabilityFlag(WriteDVDPRW) = True) And (MediaType = mtDVDPRW) Then
  116.         bCanErase = True
  117.     Else
  118.         MsgBox "Selected drive does not support Re-Writable discs of this format.", vbOKOnly + vbInformation, App.Title
  119.         Unload Me
  120.         Exit Sub
  121.     End If
  122.     'Erase Disc..Quick ?
  123.     If mobjCDPro.EraseDisc(chkQuikErase.Value = vbChecked) = False Then
  124.         'Erase command not accepted
  125.         MsgBox "Error Erasing Disc!!!", vbCritical, App.Title
  126.         Unload Me
  127.     End If
  128.            
  129. End Sub
  130. Public Sub ShowErase(objCDR As CDWriterPro)
  131.     'Set an instance of CDR so we can capture events on this form
  132.     Set mobjCDPro = objCDR
  133.     'Enable buttons
  134.     cmdCancel.Enabled = True
  135.     cmdErase.Enabled = True
  136.     'Set flag to false
  137.     mblnErasing = False
  138.     'Show me
  139.     Me.Show vbModal
  140. End Sub
  141. Private Sub Form_Unload(Cancel As Integer)
  142.     'Dont allow exit if erasing
  143.     If mblnErasing = True Then
  144.         Cancel = 1 'Cancel Exit
  145.         Exit Sub
  146.     End If
  147.     'Kill form level object
  148.     Set mobjCDPro = Nothing
  149. End Sub
  150. Private Sub mobjCDPro_EraseDiscComplete()
  151.     'Send a message to the user that erase is complete
  152.     lblStatus.Caption = "Erase operation complete!!!"
  153.     MsgBox "Erase Completed!!!", vbOKOnly + vbInformation, App.Title
  154.     'Enable buttons
  155.     cmdCancel.Enabled = True
  156.     cmdErase.Enabled = True
  157.     'Set flag to false so we can unload the form
  158.     mblnErasing = False
  159.     'Unload
  160.     Unload Me
  161. End Sub
  162. Private Sub mobjCDPro_EraseDiscStart()
  163.     'Set flag to True so we cannot unload the form until we are done erasing
  164.     mblnErasing = True
  165.     'Send message to user
  166.     lblStatus.Caption = "Erasing Disc...Please Wait!!"
  167.     'Disable buttons
  168.     cmdCancel.Enabled = False
  169.     cmdErase.Enabled = False
  170. End Sub
  171. Private Sub mobjCDPro_WriteError(ByVal WriteError As CDRPROXLibCtl.eWriteErrorType, ByVal DriveError As CDRPROXLibCtl.eCDError, ByVal sErrorInfo As String, ByVal sSenseInfo As String)
  172.     Dim strError As String
  173.     'Get the error type and
  174.     strError = "Writing Error: (" & CStr(WriteError) & ")   " & sErrorInfo & vbCrLf
  175.     'If it is a drive error, add the drive error information
  176.     'to the displayed message
  177.     If WriteError = errDriveError Then
  178.         strError = strError & GetDriveErrorMessage(DriveError) & vbCrLf & " Error Sense Data: " & sSenseInfo
  179.     End If
  180.     'Display Msg to user
  181.     MsgBox strError, vbCritical + vbOKOnly
  182.     'Reset buttons so we can unload
  183.     cmdCancel.Enabled = True
  184.     cmdErase.Enabled = True
  185.     'Set flag so the user can unload the form
  186.     mblnErasing = False
  187. End Sub
  188.